package com.ideafactory.client.views;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.ideafactory.client.ybservice.APP;

import org.xutils.x;

import java.util.List;

/**
 * Created by LiuShao on 2016/4/14.
 */
public class StoreHeadPagerAdapter extends PagerAdapter{

    private List<String> imageList;

    public StoreHeadPagerAdapter(List<String> imageList){
        this.imageList = imageList;
    }

    @Override
    public int getCount() {
        return imageList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        ImageView image = new ImageView(APP.getAPP().getApplicationContext());
        x.image().bind(image,imageList.get(position));
        container.addView(image, 0);
        return image;
    }
}
